<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info">
            <form id="notice-form">
                <div class="select-list gd">
                    <ul>
                        <li>
                            公告标题：<input type="text" name="noticeTitle"/>
                        </li>
                        <li>
                            是否阅读：<select name="isRead" th:with="type=${@dict.getType('sys_read_status')}">
                            <option value="">所有</option>
                            <option th:each="e : ${type}" th:text="${e['dictLabel']}"
                                    th:value="${e['dictValue']}"></option>
                        </select>
                        </li>
                        <li>
                            通知类型：<select name="noticeType"
                                         th:with="type=${@dict.getType('sys_notice_type')}">
                            <option value="">所有</option>
                            <option th:each="e : ${type}" th:text="${e['dictLabel']}"
                                    th:value="${e['dictValue']}"></option>
                        </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm"
                               onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group hidden-xs" id="toolbar" role="group">
            <a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.batRemove()"
               shiro:hasPermission="system:noticeRecord:remove">
                <i class="fa fa-trash-o"></i> 删除
            </a>
        </div>

        <div class="col-sm-12 select-info table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var removeFlag = [[${@permission.hasPermi('system:noticeRecord:remove')}]];
        var readFlag = [[${@permission.hasPermi('system:noticeRecord:read')}]];
        var types = [[${@dict.getType('sys_notice_type')}]];
        var reads = [[${@dict.getType('sys_read_status')}]];
        var prefix = ctx + "system/noticeRecord"

        $(function () {
            var options = {
                url: prefix + "/list",
                removeUrl: prefix + "/remove",
                modalName: "我的通知",
                search: false,
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'noticeRecordId',
                        title: '通知记录ID'
                    },
                    {
                        field: 'noticeType',
                        title: '通知类型',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(types, value);
                        }
                    },
                    {
                        field: 'noticeTitle',
                        title: '通知标题'
                    },
                    {
                        field: 'noticeContent',
                        title: '通知内容',
                        width:400

                    },
                    {
                        field: 'remark',
                        title: '备注'
                    },
                    {
                        field: 'isRead',
                        title: '阅读标记',
                        align: 'center',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(reads, value);
                        }
                    },
                    {
                        field: 'readTime',
                        title: '阅读时间'
                    },
                    {
                        field: 'sender',
                        title: '发送人'
                    },
                    {
                        field: 'createDateTimeStr',
                        title: '发布时间'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + readFlag + '" href="#" onclick="detail(\'' + row.noticeRecordId + '\')"><i class="fa fa-book"></i>阅读</a>');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.noticeRecordId + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        });


        /*操作日志-详细*/
        function detail(id) {
            var url = prefix + '/detail/' + id;
            $.modal.open("通知信息详细", url,null,500);
        };
    </script>
</body>
</html>